from common.enums import Method
from common.reporter import report
class BaseCase:
    def execute(self, client, data, headers):
        """
        执行通用测试用例
        :param client:
        :param data:
        :param headers:
        :return:
        """
        method = data.get('desc').get('method')
        if method.lower() == Method.GET:
            result = client.get(url=data.get('desc').get('url'), headers=headers)
        elif method.lower() == Method.POST:
            result = client.post(url=data.get('desc').get('url'), data=data.get('data'), headers=headers)

        assert data.get('check').get('code') == result.code
        assert data.get('check').get('message') in result.message
        # 输出测试报告
        report(data=data, result=result)
